package com.huluobo.a2308douyindemo.adapter

import android.view.View
import android.widget.Button
import android.widget.EditText
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.huluobo.a2308douyindemo.R
import com.huluobo.a2308douyindemo.bean.CommentBean
import com.huluobo.a2308douyindemo.bean.ReplyBean
import com.huluobo.a2308douyindemo.net.Const
import com.huluobo.a2308douyindemo.utils.ImageUtils
import com.huluobo.a2308douyindemo.utils.MySp
import com.huluobo.a2308douyindemo.utils.Utils.toTime
import com.huluobo.a2308douyindemo.videos.VideoViewModel
import com.huluobo.a2308douyindemo.videos.VideosFragment

/**
 *  Created by LC on 2025/10/25.
 */
class CommentAdapter() :
    BaseQuickAdapter<CommentBean, BaseViewHolder>(R.layout.item_comment) {
    val replyAdapter = ReplyAdapter()
    override fun convert(holder: BaseViewHolder, item: CommentBean) {
        ImageUtils.loadRoundImage(context, item.userlogo, holder.getView(R.id.item_comment_icon_iv), 10)
        holder.setText(R.id.item_comment_name_tv, item.nickname)
        holder.setText(R.id.item_comment_content_tv, item.content)
        holder.setText(R.id.item_comment_time, item.createtime)
        holder.setText(R.id.item_comment_like_num_tv, item.agreenum.toString())

        if (!item.replyList.isNullOrEmpty()) {
//            //初始化回复评论布局
            replyAdapter.data = item.replyList.toMutableList()
            val replyRv = holder.getView<RecyclerView>(R.id.item_comment_reply_rv)
            replyRv.layoutManager = LinearLayoutManager(context)
            replyRv.adapter = replyAdapter
//
            //如果评论的集合不为空,展示提示更多评论的布局
            holder.getView<TextView>(R.id.item_comment_reply_tv).visibility = View.VISIBLE
        }
    }
}